An operating system defines an interface between an application program and a hardware platform running the application program. As such, the operating system performs many functions on behalf of the application program. One of these functions may include servicing a request from the application program for stored data, such as a data file. Most operating systems handle such a request by generating multiple input/output (I/O) requests to hardware devices, e.g. a disk drive, to load data blocks comprising the stored data into a memory space. These multiple I/O requests are managed by a thread initialized by the operating system.
In order to maximize the amount of useful work that is done, the operating system puts threads to sleep i.e. stops executing the threads, by blocking. Basically, blocking causes a thread which is unable to run for some reason, such as when it needs resources that are temporarily unavailable, to stop executing or go to “sleep”. When a thread blocks, its local data (stacks) and its current position in its program (program counter) are saved so the thread can resume execution later. A blocked thread becomes ready for execution when the condition that has been blocking it changes, allowing the thread to unblock. The thread is thus able to continue executing its program where it left off.
In the case of the multiple I/O requests described above, when one of the I/O requests completes, the request unblocks the thread by generating an interrupt to the operating system. The operating system then continues executing the thread. However, all data needed to complete executing the thread may not be available. For example, some of the I/O requests may still be loading data blocks into the memory space. As a result, the thread is unable to complete execution and will have to be blocked again.
Unblocking a thread is an “expensive” operation from a performance standpoint, since usually many lines of code have to be executed, registers need to be refreshed, etc.
Thus, there is a need to ensure that when an operating system thread is unblocked, all data needed to complete execution of the threads are available.